package mirrormonkey.core.test.entities;

import static org.junit.Assert.assertEquals;
import mirrormonkey.commons.graph.SyncGeometry;
import mirrormonkey.core.annotations.ClientSideConstructor;
import mirrormonkey.core.annotations.NamedClientSideConstructor;
import mirrormonkey.framework.annotations.IdentityAware;

import com.jme3.math.Vector3f;
import com.jme3.scene.Mesh;
import com.jme3.scene.shape.Box;

public class ConstructorTestBox extends SyncGeometry {

	public static enum CalledConstructor {
		EMPTY, TRANSLATION_MATCHED, TRANSLATION_NAMED, IDENTITY_AWARE, SERVER_SIDE, NULL_CONSTR, ID_AWARE_NULL_CONSTR
	};

	public static final String NAMED_CONSTR = "named";

	public static final String NULL_TEST = "null_test";

	protected CalledConstructor constr;

	@ClientSideConstructor
	public ConstructorTestBox() {
		this(Vector3f.ZERO);
		constr = CalledConstructor.EMPTY;
	}

	@NamedClientSideConstructor(NAMED_CONSTR)
	public ConstructorTestBox(Object localTranslation) {
		this((Vector3f) localTranslation);
		constr = CalledConstructor.TRANSLATION_NAMED;
	}

	@ClientSideConstructor
	public ConstructorTestBox(Vector3f localTranslation) {
		this("name", localTranslation);
		constr = CalledConstructor.TRANSLATION_MATCHED;
	}

	@ClientSideConstructor
	public ConstructorTestBox(Vector3f localTranslation,
			Object localTranslation2) {
		this("name", (Vector3f) localTranslation2);
		constr = CalledConstructor.TRANSLATION_MATCHED;
	}

	@NamedClientSideConstructor(NULL_TEST)
	public ConstructorTestBox(Vector3f nullObj, Vector3f nullObj2) {
		this(Vector3f.ZERO);
		constr = CalledConstructor.NULL_CONSTR;
	}

	@ClientSideConstructor
	public ConstructorTestBox(@IdentityAware ClientConstructorTestBox previous,
			Vector3f displacement) {
		this(previous.getLocalTranslation().add(displacement));
		constr = CalledConstructor.IDENTITY_AWARE;
	}

	@ClientSideConstructor
	public ConstructorTestBox(@IdentityAware ConstructorTestBox b, Object o1,
			Object o2) {
		this();
		constr = CalledConstructor.ID_AWARE_NULL_CONSTR;
	}

	public ConstructorTestBox(@IdentityAware ConstructorTestBox previous,
			Vector3f displacement) {
		this(previous.getLocalTranslation().add(displacement));
		constr = CalledConstructor.SERVER_SIDE;
	}

	public ConstructorTestBox(String name, Vector3f position) {
		this(name, new Box(Vector3f.ZERO, 0.5f, 0.5f, 0.5f), position);
		constr = CalledConstructor.SERVER_SIDE;
	}

	public ConstructorTestBox(String name, Mesh mesh, Vector3f position) {
		super(name, mesh, position);
		constr = CalledConstructor.SERVER_SIDE;
	}

	public void assertConstructorCalled(CalledConstructor constr) {
		assertEquals(constr, this.constr);
	}

	public void assertLocalTranslation(Vector3f localTranslation) {
		assertEquals(localTranslation, this.getLocalTranslation());
	}

}
